<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('修改数据源')"/>
    <th:block th:include="include :: summernote-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-datasource-edit" th:object="${datasource}">
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">数据源编码：</label>
                    <div class="col-sm-8">
                        <input name="datasourceCode" class="form-control" required th:field="*{datasourceCode}"
                               readonly="true"/>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">数据库IP：</label>
                    <div class="col-sm-8">
                        <input name="databaseIp" class="form-control" type="text" required th:field="*{databaseIp}">
                    </div>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">数据库端口：</label>
                    <div class="col-sm-8">
                        <input id="databasePort" name="databasePort" class="form-control" type="text"
                               th:field="*{databasePort}" required>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">数据库名称：</label>
                    <div class="col-sm-8">
                        <input id="databaseName" name="databaseName" class="form-control" type="text" required
                               th:field="*{databaseName}">
                    </div>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">数据库用户名：</label>
                    <div class="col-sm-8">
                        <input class="form-control" type="text" id="databaseUsername" name="databaseUsername"
                               th:field="*{databaseUsername}" required>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">数据库密码：</label>
                    <div class="col-sm-8">
                        <input id="databasePassword" name="databasePassword" class="form-control" type="password"
                               th:field="*{databasePassword}">
                    </div>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">驱动类：</label>
                    <div class="col-sm-8">
                        <select name="databaseDriverClassName" class="form-control m-b"
                                th:with="type=${@dict.getType('sys_database_type')}">
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"
                                    th:field="*{databaseDriverClassName}"></option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">数据库标识：</label>
                    <div class="col-sm-8">
                        <select name="databaseFlag" class="form-control m-b"
                                th:with="type=${@dict.getType('sys_database_flag')}">
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"
                                    th:field="*{databaseFlag}"></option>
                        </select>
                    </div>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-sm-12">
                <div class="form-group">
                    <label class="col-xs-2 control-label">所属租户：</label>
                    <div class="col-xs-10">
                        <select id="tenantCode" name="tenantCode" class="form-control m-b" th:field="*{tenantCode}">
                            <option th:each="tenant:${tenants}" th:value="${tenant.tenantCode}"
                                    th:text="${tenant.tenantName}"></option>
                        </select>
                    </div>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-sm-12">
                <div class="form-group">
                    <label class="col-xs-2 control-label">备注：</label>
                    <div class="col-xs-10">
                        <textarea name="remark" maxlength="500" class="form-control" rows="3"
                                  th:text="*{remark}"></textarea>
                    </div>
                </div>
            </div>
        </div>

    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: summernote-js"/>
<script type="text/javascript">
    var prefix = ctx + "system/datasource";

    $("#form-datasource-edit").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/edit", $('#form-datasource-edit').serialize());
        }
    }
</script>
</body>
</html>
